package com.sbio.udiapp.util;

import android.media.MediaPlayer;
import android.util.Log;

import com.sbio.udiapp.R;
import com.sbio.udiapp.di.ActivityManager;

public class SoundPlayerUtil {


    private static MediaPlayer mediaPlayer;

    public static void playCustomSound(int audioResourceId) {
        if (mediaPlayer != null && mediaPlayer.isPlaying()) {
            mediaPlayer.stop();
            mediaPlayer.reset();
        }
        mediaPlayer = MediaPlayer.create(ActivityManager.getCurrentActivity(), audioResourceId);
        mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                mediaPlayer.reset();
            }
        });
        mediaPlayer.start();
    }


    public static void playSuccess() {
        SoundPlayerUtil.playCustomSound(R.raw.success);
    }


    public static void playFail() {
        SoundPlayerUtil.playCustomSound(R.raw.fail);
    }

    public static void playWait() {
        playCustomSound(R.raw.wait);
    }




}
